home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.2 / AppShell / examples / projlist / projlist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  8.1 KB  |  262 lines

  1. /* projlist.h
  2.  * Copyright (C) 1990 Commodore-Amiga, Inc.
  3.  * written by David N. Junod
  4.  *
  5.  * project list requester
  6.  * application-specific arrays & definitions
  7.  *
  8.  */
  9.  
  10. /* The AppShell maintains some basic information on the application.  Someday
  11.  * it will provide a standard About requester that contains this information
  12.  * plus the application's tool icon.
  13.  */
  14. #define    APPNAME "Project List"
  15. #define    APPVERS    "ProjList 36.3 (14-Jun-90)"
  16. #define    APPCOPY "Copyright (C) 1990 Commodore-Amiga, Inc."
  17. #define    APPAUTH "David N. Junod"
  18.  
  19. /* These are the function prototypes for all the application implemented
  20.  * functions used in this example. */
  21. VOID NewFunc      (struct AppInfo *, STRPTR, struct TagItem *);
  22. VOID BModListFunc (struct AppInfo *, STRPTR, struct TagItem *);
  23. VOID AModListFunc (struct AppInfo *, STRPTR, struct TagItem *);
  24. VOID QuitFunc     (struct AppInfo *, STRPTR, struct TagItem *);
  25. VOID OkayFunc     (struct AppInfo *, STRPTR, struct TagItem *);
  26. VOID PreviousFunc (struct AppInfo *, STRPTR, struct TagItem *);
  27. VOID NextFunc     (struct AppInfo *, STRPTR, struct TagItem *);
  28. VOID RemoveFunc   (struct AppInfo *, STRPTR, struct TagItem *);
  29. VOID CancelFunc   (struct AppInfo *, STRPTR, struct TagItem *);
  30. VOID SelectFunc   (struct AppInfo *, STRPTR, struct TagItem *);
  31. VOID ListFunc     (struct AppInfo *, STRPTR, struct TagItem *);
  32. VOID SwapFunc     (struct AppInfo *, STRPTR, struct TagItem *);
  33.  
  34. /* Each public function gets a numeric ID assigned to it.  */
  35. enum
  36. {
  37.     DUMMYID = APSH_USER_ID,
  38.     OkayID,
  39.     MyPrevID,
  40.     MyNextID,
  41.     MyRemvID,
  42.     CancelID,
  43.     ListID,
  44.     SwapID,
  45.     BModListID,
  46.     AModListID,
  47.     LAST_ID
  48. };
  49.  
  50. /* The AppShell will convert this array into function table entries and will
  51.  * add them to the function table list.  Using the APSH_FF_PRIVATE flag, we
  52.  * are able to have functions that can't be triggered by the user. */
  53. struct Funcs FTable[] =
  54. {
  55.     {"NEW",    NewFunc,    NewID,},
  56.     {"QUIT",    QuitFunc,    QuitID,},
  57.     {"OKAY",    OkayFunc,    OkayID,},
  58.     {"PREVIOUS",PreviousFunc,    MyPrevID,},
  59.     {"NEXT",    NextFunc,    MyNextID,},
  60.     {"REMOVE",  RemoveFunc,    MyRemvID,},
  61.     {"CANCEL",  CancelFunc,    CancelID,},
  62.     {"SELECT",  SelectFunc,    SelectID,},
  63.     {"LIST",    ListFunc,    ListID, NULL, NULL, APSH_FF_PRIVATE},
  64.     {"SWAP",    SwapFunc,    SwapID,},
  65.     {"BMOD",    BModListFunc,    BModListID,},
  66.     {"AMOD",    AModListFunc,    AModListID,},
  67.     {NULL,      NO_FUNCTION,}    /* end of array */
  68. };
  69.  
  70. /* All text used in the application must be defined in a text array.  Then
  71.  * referred to by numeric ID. */
  72. STRPTR app_deftext[] =
  73. {
  74.   NULL,                    /*  0 */
  75.   "Project List",            /*  1 */
  76.   "Okay",                /*  2 */
  77.   "Previous",                /*  3 */
  78.   "Next",                /*  4 */
  79.   "Remove",                /*  5 */
  80.   "Cancel",                /*  6 */
  81.   NULL
  82. };
  83.  
  84. /* Objects may use TagItems to describe additional attributes.  The attributes
  85.  * in this case are defined by GadTools.  */
  86. struct TagItem selecttags[] =
  87. {
  88.     {GTST_MaxChars, 512L},
  89.     {TAG_DONE,},
  90. };
  91.  
  92. /* Because we don't no the gadget address for the text gadget to assign to
  93.  * the list, we provide the name assigned to the object instead.  We also
  94.  * provide a function ID to call when the gadget is selected when either
  95.  * ALT key is pressed. */
  96. struct TagItem listtags[] =
  97. {
  98.     {GTLV_ShowSelected, (ULONG)"SELECT"},
  99.     {APSH_ObjAltHit,    SwapID},
  100.     {TAG_DONE,},
  101. };
  102.  
  103. /* All objects (such as gadgets) that are going to be contained in the window
  104.  * are placed in the object array. */
  105. struct Object objects[] =
  106. {
  107.     {&objects[1], 0, OBJ_Window, NULL, NULL, NULL, "MAIN", 1L,
  108.      {1, 1, 0, 0}, },
  109.  
  110.     {&objects[2], 1, OBJ_Button, OkayID, NULL, RETURN, "OKAY", 2L,
  111.      { 12, 92, 80, 12}, },
  112.     {&objects[3], 1, OBJ_Button, MyPrevID, NULL, 'p', "PREVIOUS", 3L,
  113.      {102, 92, 80, 12}, },
  114.     {&objects[4], 1, OBJ_Button, MyNextID, NULL, 'n', "NEXT", 4L,
  115.      {192, 92, 80, 12}, },
  116.     {&objects[5], 1, OBJ_Button, MyRemvID, NULL, 'r', "REMOVE",   5L,
  117.      {282, 92, 80, 12}, },
  118.     {&objects[6], 1, OBJ_Button, CancelID, NULL, ESC, "CANCEL",   6L,
  119.      {372, 92, 80, 12}, },
  120.  
  121.     {&objects[7], 2, OBJ_String, SelectID, NULL, 's', "SELECT", NULL,
  122.      { 12,  0,308, 14}, selecttags, },
  123.  
  124.     {NULL,        2, OBJ_Listview, ListID, NULL,   NULL, "LIST",   NULL,
  125.      { 12, 15,308, 70}, listtags, },
  126. };
  127.  
  128. /* This is a GadTools menu array.  Eventually there will be a preprocessor
  129.  * to convert text ID's into text for internationalization. */
  130. struct NewMenu main_menu[] =
  131. {
  132.     {NM_TITLE, "Project",         0, 0, 0, 0, },
  133.     {NM_ITEM,  "New",           "N", 0, 0, V ( NewID ), },
  134.     {NM_ITEM,  "Quit",          "Q", 0, 0, V ( QuitID ), },
  135.  
  136.     {NM_TITLE, "Extras",          0, 0, 0, 0, },
  137.     {NM_ITEM,  "Command Shell", "E", 0, 0, V ( CMDShellID ), },
  138.  
  139.     {NM_END, },
  140. };
  141.  
  142. /* required libraries */
  143. extern ULONG SysBase;
  144. ULONG GadToolsBase;
  145. ULONG GfxBase;
  146. ULONG IconBase;
  147. ULONG IntuitionBase;
  148. ULONG LayersBase;
  149.  
  150. /* This tag array is used to open and close the shared system libraries
  151.  * needed by our application. */
  152. struct TagItem Our_Libs[] =
  153. {
  154.     {APSH_LibVersion,    36L},
  155.     {APSH_LibStatus,    REQUIRED},
  156.     {APSH_LibNameTag,    APSH_GadTools},
  157.     {APSH_LibBase,    &GadToolsBase},
  158.     {APSH_LibNameTag,    APSH_Gfx},
  159.     {APSH_LibBase,    &GfxBase},
  160.     {APSH_LibNameTag,    APSH_Icon},
  161.     {APSH_LibBase,    &IconBase},
  162.     {APSH_LibNameTag,    APSH_Intuition},
  163.     {APSH_LibBase,    &IntuitionBase},
  164.     {APSH_LibNameTag,    APSH_Layers},
  165.     {APSH_LibBase,    &LayersBase},
  166.     {TAG_DONE,}
  167. };
  168.  
  169. /* These tags describe the Simple IPC user interface.  In this case, the
  170.  * main use is to enforce the single invocation requirements of the
  171.  * application */
  172. struct TagItem Handle_SIPC[] =
  173. {
  174.     {APSH_Setup,    setup_sipcA},
  175.     {APSH_Status,    P_ACTIVE | P_SINGLE},
  176.     {APSH_Rating,    OPTIONAL},
  177.     {TAG_DONE,}
  178. };
  179.  
  180. /* These tags describe the ARexx user interface.  The default macro file
  181.  * extension is proj. */
  182. struct TagItem Handle_AREXX[] =
  183. {
  184.     {APSH_Setup,    setup_arexxA},
  185.     {APSH_Extens,    (ULONG)"proj"},
  186.     {APSH_Status,    P_ACTIVE | P_SINGLE},
  187.     {APSH_Rating,    OPTIONAL},
  188.     {TAG_DONE,}
  189. };
  190.  
  191. /* These tags describe the Command Shell user interface. */
  192. struct TagItem Handle_DOS[] =
  193. {
  194.     {APSH_Setup,    setup_dosA},
  195.     {APSH_Status,    P_INACTIVE},
  196.     {APSH_Rating,    OPTIONAL},
  197.     {TAG_DONE,}
  198. };
  199.  
  200. /* These tags describe the window environment */
  201. struct TagItem windowenv[] =
  202. {
  203.     {APSH_NameTag,    (ULONG)"MAIN"},    /* name to give to window */
  204.     {APSH_Objects,    (ULONG)objects},/* object list */
  205.     {APSH_GTMenu,    (ULONG)main_menu},
  206.     {TAG_DONE,}
  207. };
  208.  
  209. /* These tags describe the Intuition user interface. */
  210. struct TagItem Handle_IDCMP[] =
  211. {
  212.     {APSH_Setup,    setup_idcmpA},
  213.     {APSH_WindowEnv,    (ULONG)windowenv},
  214.     {APSH_Status,    P_ACTIVE},
  215.     {APSH_Rating,    REQUIRED},
  216.     {TAG_DONE,}
  217. };
  218.  
  219. /* These tags describe an AppWindow environment.  The AppWindow will be
  220.  * attached to the window named MAIN and dropped icons will be added to the
  221.  * main project list.  Since the project list is attached to a list gadget,
  222.  * we must remove the list from the gadget before modifying the list.  Hence
  223.  * the before drop and after drop functions. */
  224. struct TagItem appwinenv[] =
  225. {
  226.     {APSH_NameTag,    (ULONG)"MAIN"},    /* Window to make into AppWindow */
  227.     {APSH_CmdFlags, APSH_WBF_PROJLIST}, /* add the icons to the project list */
  228.     {APSH_AppBDrop,    BModListID},    /* function before drop */
  229.     {APSH_AppADrop,    AModListID},    /* function after drop */
  230.     {TAG_DONE,}
  231. };
  232.  
  233. /* These tags describe the Workbench user interface. */
  234. struct TagItem Handle_WB[] =
  235. {
  236.     {APSH_Setup,    setup_wbA},
  237.     {APSH_AppWindowEnv,    (ULONG)appwinenv},
  238.     {APSH_Status,    P_ACTIVE},
  239.     {APSH_Rating,    OPTIONAL},
  240.     {TAG_DONE,}
  241. };
  242.  
  243. /* This is the main tag list used to describe our application's multiple
  244.  * user interfaces. */
  245. struct TagItem Our_App[] =
  246. {
  247.     {APSH_AppName,    (ULONG)APPNAME},
  248.     {APSH_AppVersion,    (ULONG)APPVERS},
  249.     {APSH_AppCopyright,    (ULONG)APPCOPY},
  250.     {APSH_AppAuthor,    (ULONG)APPAUTH},
  251.     {APSH_FuncTable,    (ULONG)FTable},
  252.     {APSH_DefText,    (ULONG)app_deftext},
  253.     {APSH_OpenLibraries,(ULONG)Our_Libs},
  254.     {APSH_AddHandler,    (ULONG)Handle_SIPC},
  255.     {APSH_AddHandler,    (ULONG)Handle_AREXX},
  256.     {APSH_AddHandler,    (ULONG)Handle_DOS},
  257.     {APSH_AddHandler,    (ULONG)Handle_IDCMP},
  258.     {APSH_AddHandler,    (ULONG)Handle_WB},
  259.     {APSH_AppInit,    AModListID},
  260.     {TAG_DONE,}
  261. };
  262.